package vn.adcc.webapp.action;


import java.io.Serializable;
import java.util.List;
import vn.adcc.model.Customer;
import vn.adcc.service.CustomerManager;

/**
 * JSF Page class to handle editing a customer with a form.
 *
 * @author duccom
 */
public class CustomerList extends BasePage implements Serializable {
    private CustomerManager customerManager;
    private String query;
    
    public CustomerList(){
        setSortColumn("name");
    }
    public String search() {
        return "success";
    }
    
    public List<Customer> getCustomers() {
        if (query != null && !"".equals(query.trim())) {
            return customerManager.search(query);
        } else {
            List<Customer> customerList = customerManager.getCustomers();
            return sort(customerList);
        }
    }

    /**
     * @return the query
     */
    public String getQuery() {
        return query;
    }

    /**
     * @param query the query to set
     */
    public void setQuery(String query) {
        this.query = query;
    }

    /**
     * @return the customerManager
     */
    public CustomerManager getCustomerManager() {
        return customerManager;
    }

    /**
     * @param customerManager the customerManager to set
     */
    public void setCustomerManager(CustomerManager customerManager) {
        this.customerManager = customerManager;
    }
}